home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
mint
/
lib
/
mntlib44.zoo
/
mntlib
/
libgcc2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-14
|
28KB
|
1,330 lines
/* More subroutines needed by GCC output code on some machines. */
/* Compile this one with gcc. */
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* As a special exception, if you link this library with files
compiled with GCC to produce an executable, this does not cause
the resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
#ifndef atarist
/* It is incorrect to include config.h here, because this file is being
compiled for the target, and hence definitions concerning only the host
do not apply. */
#include "tconfig.h"
#include "machmode.h"
#ifndef L_trampoline
#include "gstddef.h"
#endif
/* Don't use `fancy_abort' here even if config.h says to use it. */
#ifdef abort
#undef abort
#endif
#else
/* For the atari, include the relevant parts of config/m68k.h directly. */
#ifndef __mc68000__
#define __mc68000__ 1
#ifdef __M68020__
#define __mc68020__ 1
#endif
#endif
#if __GNUC__ < 2
#error This file is for GCC version 2 only.
#endif
#ifndef L_trampoline
#include <stddef.h>
#endif
#if defined(XFLOAT_ENABLE) && (__GNUC__ > 2 || __GNUC_MINOR__ >= 4)
/* Define for XFmode extended real floating point support. */
#define LONG_DOUBLE_TYPE_SIZE 96
#else
/* Don't try using XFmode. */
#define LONG_DOUBLE_TYPE_SIZE 64
#endif
/* Define this if most significant bit is lowest numbered
in instructions that operate on numbered bit-fields.
This is true for 68020 insns such as bfins and bfexts. */
#define BITS_BIG_ENDIAN 1
/* Define this if most significant word of a multiword number is the lowest
numbered. */
/* For 68000 we can decide arbitrarily
since there are no machine instructions for them.
So let's be consistent. */
#define WORDS_BIG_ENDIAN 1
/* number of bits in an addressable storage unit */
#define BITS_PER_UNIT 8
/* Width in bits of a "word", which is the contents of a machine register.
Note that this is not necessarily the width of data type `int';
if using 16-bit ints on a 68000, this would still be 32.
But on a machine with 16-bit registers, this would be 16. */
#define BITS_PER_WORD 32
/* This is the library routine that is used
to transfer control from the trampoline
to the actual nested function. */
/* A colon is used with no explicit operands
to cause the template string to be scanned for %-constructs. */
/* The function name __transfer_from_trampoline is not actually used.
The function definition just permits use of "asm with operands"
(though the operand list is empty). */
#define TRANSFER_FROM_TRAMPOLINE \
void \
__transfer_from_trampoline () \
{ \
register char *a0 asm ("%a0"); \
asm (".globl ___trampoline"); \
asm ("___trampoline:"); \
asm volatile ("move%.l %0,%@" : : "m" (a0[22])); \
asm volatile ("move%.l %1,%0" : "=a" (a0) : "m" (a0[18])); \
asm ("rts":); \
}
#endif /* atarist */
/* In the first part of this file, we are interfacing to calls generated
by the compiler itself. These calls pass values into these routines
which have very specific modes (rather than very specific types), and
these compiler-generated calls also expect any return values to have
very specific modes (rather than very specific types). Thus, we need
to avoid using regular C language type names in this part of the file
because the sizes for those types can be configured to be anything.
Instead we use the following special type names. */
typedef unsigned int UQItype __attribute__ ((mode (QI)));
typedef int SItype __attribute__ ((mode (SI)));
typedef unsigned int USItype __attribute__ ((mode (SI)));
typedef int DItype __attribute__ ((mode (DI)));
typedef unsigned int UDItype __attribute__ ((mode (DI)));
typedef float SFtype __attribute__ ((mode (SF)));
typedef float DFtype __attribute__ ((mode (DF)));
#if LONG_DOUBLE_TYPE_SIZE == 96
typedef float XFtype __attribute__ ((mode (XF)));
#endif
#if LONG_DOUBLE_TYPE_SIZE == 128
typedef float TFtype __attribute__ ((mode (TF)));
#endif
#if BITS_PER_WORD==16
typedef int word_type __attribute__ ((mode (HI)));
#endif
#if BITS_PER_WORD==32
typedef int word_type __attribute__ ((mode (SI)));
#endif
#if BITS_PER_WORD==64
typedef int word_type __attribute__ ((mode (DI)));
#endif
/* Make sure that we don't accidentally use any normal C language built-in
type names in the first part of this file. Instead we want to use *only*
the type names defined above. The following macro definitions insure
that if we *do* accidentally use some normal C language built-in type name,
we will get a syntax error. */
#define char bogus_type
#define short bogus_type
#define int bogus_type
#define long bogus_type
#define unsigned bogus_type
#define float bogus_type
#define double bogus_type
#define SI_TYPE_SIZE (sizeof (SItype) * BITS_PER_UNIT)
/* DIstructs are pairs of SItype values in the order determined by
WORDS_BIG_ENDIAN. */
#if WORDS_BIG_ENDIAN
struct DIstruct {SItype high, low;};
#else
struct DIstruct {SItype low, high;};
#endif
/* We need this union to unpack/pack DImode values, since we don't have
any arithmetic yet. Incoming DImode parameters are stored into the
`ll' field, and the unpacked result is read from the struct `s'. */
typedef union
{
struct DIstruct s;
DItype ll;
} DIunion;
#if defined (L_udivmoddi4) || defined (L_muldi3) || defined (L_udiv_w_sdiv)
#include "longlong.h"
#endif /* udiv or mul */
extern DItype __fixunssfdi (SFtype a);
extern DItype __fixunsdfdi (DFtype a);
#if LONG_DOUBLE_TYPE_SIZE == 96
extern DItype __fixunsxfdi (XFtype a);
#endif
#if LONG_DOUBLE_TYPE_SIZE == 128
extern DItype __fixunstfdi (TFtype a);
#endif
#if defined (L_negdi2) || defined (L_divdi3) || defined (L_moddi3)
#if defined (L_divdi3) || defined (L_moddi3)
static inline
#endif
DItype
__negdi2 (u)
DItype u;
{
DIunion w;
DIunion uu;
uu.ll = u;
w.s.low = -uu.s.low;
w.s.high = -uu.s.high - ((USItype) w.s.low > 0);
return w.ll;
}
#endif
#ifdef L_lshldi3
DItype
__lshldi3 (u, b)
DItype u;
SItype b;
{
DIunion w;
SItype bm;
DIunion uu;
if (b == 0)
return u;
uu.ll = u;
bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
if (bm <= 0)
{
w.s.low = 0;
w.s.high = (USItype)uu.s.low << -bm;
}
else
{
USItype carries = (USItype)uu.s.low >> bm;
w.s.low = (USItype)uu.s.low << b;
w.s.high = ((USItype)uu.s.high << b) | carries;
}
return w.ll;
}
#endif
#ifdef L_lshrdi3
DItype
__lshrdi3 (u, b)
DItype u;
SItype b;
{
DIunion w;
SItype bm;
DIunion uu;
if (b == 0)
return u;
uu.ll = u;
bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
if (bm <= 0)
{
w.s.high = 0;
w.s.low = (USItype)uu.s.high >> -bm;
}
else
{
USItype carries = (USItype)uu.s.high << bm;
w.s.high = (USItype)uu.s.high >> b;
w.s.low = ((USItype)uu.s.low >> b) | carries;
}
return w.ll;
}
#endif
#ifdef L_ashldi3
DItype
__ashldi3 (u, b)
DItype u;
SItype b;
{
DIunion w;
SItype bm;
DIunion uu;
if (b == 0)
return u;
uu.ll = u;
bm = (sizeof (SItype) * BITS_PER_UNIT) - b;
if (bm <= 0)
{
w.s.low = 0;
w.s.high = (USItype)uu.s.low << -bm;
}
else
{
USItype carries = (USItype)uu.s.low >> bm;
w.s.low = (USItype)uu.s.low << b;
w.s.high